﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using Models;
using BLL;
using System.Data.Entity;
namespace CMS项目.Areas.HouTaiArea.Controllers
{
    public class IndexController : Controller
    {
        BLLCMS_Article BLLCMS_Article = new BLLCMS_Article();
        // GET: HouTaiArea/Index
        public ActionResult Index()
        {
            return View();
        }
        [HttpPost]
        public ActionResult Index(string Uname, string upwd)
        {
            using (var wdb = new KQCMS())
            {
                var list = wdb.CMS_User.Where(u => u.Uname.Equals(Uname) && u.upwd.Equals(upwd)).Count();
                if (list > 0)
                {
                    return Content("alter(登陆成功)");
                    //return RedirectToAction("add.cshtml");
                }
                else
                {
                    return View();
                }
            }
        }

        public ActionResult add()
        {
            return View();
        }
        public ActionResult del()
        {
            return View();
        }
<<<<<<< HEAD
        public ActionResult Add1()
        {
            return View();
        }

=======
        public ActionResult login()
        {
            return View();
        }
        //分页查询所有的评论
        [HttpGet]
        public ActionResult GetView_CommentAU()
        {
            var list = (BLL_View_CommentAU.GetView_CommentAUs(1, 3, null, null).Data).ToList();
            var count = BLL_View_CommentAU.GetView_CommentAUs(1, 3, null, null).Count;
            ViewBag.count = count;
            return View(list);
            //return Json(BLL_View_CommentAU.GetView_CommentAUs(1, 3, null, null), JsonRequestBehavior.AllowGet);
        }
        [HttpGet]
        public ActionResult AddCMS_Comment()
        {
            using (var db = new KQCMS())
            {
                ViewBag.Article = new SelectList(db.CMS_Article.ToList(), "aid", "title");
                ViewBag.User = new SelectList(db.CMS_User.ToList(), "Uid", "nname");
            }
            return View();
        }
        public ActionResult AddCMS_Comment(CMS_Comment cm)
        {
            int count = BLL_View_CommentAU.AddCMS_Comment(cm);
            if (count > 0)
            {
                return Content("alert('成功')");
            }
            else
            {
                return Content("alert('失败')");
            }
        }

        public ActionResult SelectPage(int? pageindex, int? pagesize)
        {
            return Json(BLLCMS_Article.GetPageCMS_Articles((int)pageindex, (int)pagesize, null), JsonRequestBehavior.AllowGet);
        }
        [HttpPost]
        public ActionResult SelectPage(int? pageindex, int? pagesize, string aid)
        {
            return Json(BLLCMS_Article.GetPageCMS_Articles((int)pageindex, (int)pagesize, aid));
        }
        [HttpPost]
        public ActionResult DelectArticle(int? id)
        {
            return Json(BLLCMS_Article.DelectArticle(id));
        }
>>>>>>> 74a404fc99e95fc46be42ab829b5008e4b409c0a
    }
}